﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DHNetSDK;

namespace DLLTest.OpertionClass
{
    class PtzOpertion
    {
        /// <summary>
        /// 大华云台控制
        /// </summary>
        /// <param name="btname"></param>
        /// <param name="pLoginID"></param>
        /// <param name="channelId"></param>
        /// <param name="stepValue"></param>
        public void DHPTZContrer(string btname, int pLoginID, int channelId, ushort stepValue, int btn)
        {
            # region <<**********云台控制代码**********>>
            if (btn == 1)//云台控制按钮按下
            {
                switch (btname)
                {
                    case "btnZoomP"://放大
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_ADD_CONTROL, stepValue, false);
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_ADD_CONTROL, stepValue, true);
                        break;
                    case "btnZoomD"://缩小
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_DEC_CONTROL, stepValue, false);
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_DEC_CONTROL, stepValue, true);
                        break;
                    case "btnFocusP"://焦距近
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_ADD_CONTROL, stepValue, false);
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_ADD_CONTROL, stepValue, true);
                        break;
                    case "btnFocusD"://焦距远
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_DEC_CONTROL, stepValue, false);
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_DEC_CONTROL, stepValue, true);
                        break;
                    case "btnIrisOpen"://光圈开
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_ADD_CONTROL, stepValue, false);
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_ADD_CONTROL, stepValue, true);
                        break;
                    case "btnIrisClose"://光圈关
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_DEC_CONTROL, stepValue, false);
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_DEC_CONTROL, stepValue, true);
                        break;
                }
            }
            if (btn == 2)//云台控制[按钮鼠标按下]处理
            {
                switch (btname)
                {
                    case "btnLEFTTOP"://左上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_LEFTTOP, stepValue, stepValue, false);
                        break;
                    case "btnTOP"://上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_UP_CONTROL, stepValue, false);
                        break;
                    case "btnRIGHTDOWN"://右下
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_RIGHTDOWN, stepValue, stepValue, false);
                        break;
                    case "btnLEFT"://左
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_LEFT_CONTROL, stepValue, false);
                        break;
                    case "btnDOWN"://下
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_DOWN_CONTROL, stepValue, false);
                        break;
                    case "btnRIGHT"://右
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_RIGHT_CONTROL, stepValue, false);
                        break;
                    case "btnRIGHTTOP"://右上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_RIGHTTOP, stepValue, stepValue, false);
                        break;
                    case "btnLEFTDOWN"://右上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_LEFTDOWN, stepValue, stepValue, false);
                        break;
                    //case "btnZoomP"://放大
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_ADD_CONTROL, stepValue, false);
                    //    break;
                    //case "btnZoomD"://缩小
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_DEC_CONTROL, stepValue, false);
                    //    break;
                    //case "btnFocusP"://焦距近
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_ADD_CONTROL, stepValue, false);
                    //    break;
                    //case "btnFocusD"://焦距远
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_DEC_CONTROL, stepValue, false);
                    //    break;
                    //case "btnIrisOpen"://光圈开
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_ADD_CONTROL, stepValue, false);
                    //    break;
                    //case "btnIrisClose"://光圈关
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_DEC_CONTROL, stepValue, false);
                    //    break;
                }
            }
            if (btn == 3)//云台控制[按钮鼠标抬起]处理
            {
                switch (btname)
                {
                    case "btnLEFTTOP"://左上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_LEFTTOP, stepValue, stepValue, true);
                        break;
                    case "btnTOP"://上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_UP_CONTROL, stepValue, true);
                        break;
                    case "btnRIGHTDOWN"://右下
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_RIGHTDOWN, stepValue, stepValue, true);
                        break;
                    case "btnLEFT"://左
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_LEFT_CONTROL, stepValue, true);
                        break;
                    case "btnDOWN"://下
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_DOWN_CONTROL, stepValue, true);
                        break;
                    case "btnRIGHT"://右
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_RIGHT_CONTROL, stepValue, true);
                        break;
                    case "btnRIGHTTOP"://右上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_RIGHTTOP, stepValue, stepValue, true);
                        break;
                    case "btnLEFTDOWN"://右上
                        DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.EXTPTZ_LEFTDOWN, stepValue, stepValue, true);
                        break;
                    //case "btnZoomP"://放大
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_ADD_CONTROL, stepValue, true);
                    //    break;
                    //case "btnZoomD"://缩小
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_ZOOM_DEC_CONTROL, stepValue, true);
                    //    break;
                    //case "btnFocusP"://焦距近
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_ADD_CONTROL, stepValue, true);
                    //    break;
                    //case "btnFocusD"://焦距远
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_FOCUS_DEC_CONTROL, stepValue, true);
                    //    break;
                    //case "btnIrisOpen"://光圈开
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_ADD_CONTROL, stepValue, true);
                    //    break;
                    //case "btnIrisClose"://光圈关
                    //    DHClient.DHPTZControl(pLoginID, channelId, PTZ_CONTROL.PTZ_APERTURE_DEC_CONTROL, stepValue, true);
                    //    break;
                }
            }
            #endregion
        }
    }
    
}
